{include file="public/header" /}
<style>
    .layui-input{
        display: inline-block;
        width:70%;
    }
    .lianghang{
        width: 50%;
        float: left
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>商铺详情</h5>
        <div class="ibox-tools">
            <a class="collapse-link">
                <i class="fa fa-chevron-up"></i>
            </a>
        </div>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">
            <div class="lianghang">
                <label>订单编号：</label>
                <input type="text" class="layui-input" value="{$data.yy_number}" disabled>
            </div>
            <div class="lianghang">
                <label>代理名称：</label>
                <input type="text" class="layui-input" value="{$data.user_username}" disabled>
            </div>
            <div class="lianghang">
                <label>代理电话：</label>
                <input type="text" class="layui-input" value="{$data.user_phone}" disabled>
            </div>
            <div class="lianghang">
                <label>代理店铺名称：</label>
                <input type="text" class="layui-input" value="{$data.user_shopname}" disabled>
            </div>
            <div class="lianghang">
                <label>订单重量：</label>
                <input type="text" class="layui-input" value="{$data.yy_weight}" disabled>
            </div>
            <div class="lianghang">
                <label>订单时间：</label>
                <input type="text" class="layui-input" value="{$data.yy_createtime}" disabled>
            </div>
            <div class="lianghang">
                <label>当天铅价：</label>
                <input type="text" class="layui-input" value="{$data.yy_price} 元/吨" disabled>
            </div>
            <div class="lianghang">
                <label>当天铅价补贴：</label>
                <input type="text" class="layui-input" value="{$data.yy_butie} 元/吨" disabled>
            </div>
            <div class="lianghang">
                <label>订单状态：</label>
                {if $data.yy_status == 1}
                <input type="text" class="layui-input" value="未确认" disabled>
                {/if}
                {if $data.yy_status == 2}
                    {if $data.yy_admin_image}
                    <input type="text" class="layui-input" value="已确认(有凭证)" disabled>
                    {else /}
                    <input type="text" class="layui-input" value="已确认(无凭证)" disabled>
                    {/if}
                {/if}
                {if $data.yy_status == 3}
                <input type="text" class="layui-input" value="已完成" disabled>
                {/if}
                {if $data.yy_status == 4}
                <input type="text" class="layui-input" value="已取消" disabled>
                {/if}
            </div>
            <div class="lianghang">
                <label>订单是否删除：</label>
                {if $data.yy_del == 1}
                <input type="text" class="layui-input" value="正常" disabled>
                {else /}
                <input type="text" class="layui-input" value="已删除" disabled>
                {/if}
            </div>
            <div class="lianghang">
                <label>是否打钱：</label>
                {if $data.yy_admin_status == 1}
                <input type="text" class="layui-input" value="未打钱" disabled>
                {else /}
                <input type="text" class="layui-input" value="已打钱" disabled>
                {/if}
            </div>
            <div class="lianghang">
                <label>是否上传凭证：</label>
                {if $data.yy_admin_image}
                <input type="text" class="layui-input" value="已上传凭证" disabled>
                {else /}
                <input type="text" class="layui-input" value="未上传凭证" disabled>
                {/if}
            </div>
            <div style="width: 100%;height: 1px;clear: both"></div>
            {if $data.yy_admin_image}
            <div>
                <label class="layui-form-label">凭证：</label>
                <div class="layui-input-block">
                    <div class="layui-upload-list" >
                        {foreach name="$data.yy_admin_image" item="vo"}
                        <img src="{$vo}" style="width:40%;cursor:pointer;" onerror="this.src='/static/admin/images/no_img.jpg'">
                        {/foreach}
                    </div>
                </div>
            </div>
            {/if}
            <div style="width: 100%;height: 1px;clear: both"></div>
            <div class="layui-form-item layui-col-xs-offset1 layui-col-xs8">
                <div class="layui-input-block">
                    <button class="layui-btn" onclick="history.go(-1)">返回</button>
                    <!---->
                    {if $data.yy_del == 1}
                        {if $data.yy_status == 1}
                        <a href="javascript:;" onclick="agreeyy({$data.yy_id})" class="layui-btn" title="确定">是否确认订单</a>
                        {/if}
                        {if $data.yy_status == 2 && $data.yy_admin_image}
                        <a href="javascript:;" onclick="moneyyy({$data.yy_id})" class="layui-btn" title="打款">打款</a>
                        {/if}
                    {/if}
                    <!---->
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
</body>
</html>
<script>
    $('.layui-form').viewer({
        url: 'data-original',
    });
    function agreeyy(id){
        layer.confirm('确认同意此预约吗？', {
            btn: ['同意','拒绝'] //按钮
        }, function(){
            agreeyyAjax(id,2)
        }, function(){
            agreeyyAjax(id,4)
        });
    }
    function moneyyy(id){
        layer.prompt({
            formType: 2,
            value: '',
            title: '输入金额（最多保留两位小数）',
            area: ['200px', '50px'] //自定义文本域宽高
        }, function(value, index, elem){
            layer.confirm('确认？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                layer.closeAll();
                moneyyyAjax(id,value)
            }, function(){
                layer.closeAll();
            });

        });
    }

    function agreeyyAjax(id,value){
        $.ajax({
            url:"{:url('agreeyy')}",
            type:'post',
            data:'id='+id + '&status=' + value,
            dataType:'json',
            success:function(res){
                if(res.code == 200){
                    layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                        //重载当前页表格
                        location.reload();
                    })
                }else if(res.code == 100){
                    wk.error(res.msg,'',2);
                }
            }
        })
    }

    function moneyyyAjax(id,value){
        $.ajax({
            url:"{:url('moneyyy')}",
            type:'post',
            data:'id='+id + '&money=' + value,
            dataType:'json',
            success:function(res){
                if(res.code == 200){
                    layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                        //重载当前页表格
                        location.reload();
                    })
                }else if(res.code == 100){
                    wk.error(res.msg,'',2);
                }
            }
        })
    }
</script>